#include <iostream>
#include <memory>
#include <functional>
#include "TcpServer.hpp"
#include "Dict.hpp"
using namespace std;
void Usage(std::string pro)
{
    std::cout << "Usage:\n\t" << pro << "local_port\n";
}

int main(int argn, char *argv[])
{
    if (argn < 2)
    {
        Usage(argv[0]);
        exit(USAGE_ERROR);
    }
    uint16_t port = stoi(argv[1]);
    
    DictNamespace::Dict dict;
    func_t Translate = std::bind(&DictNamespace::Dict::Translate, &dict, std::placeholders::_1, std::placeholders::_2);    // 任务逻辑
    
    
    unique_ptr<TcpServer> tsptr = make_unique<TcpServer>(port, Translate);  // 网络部分
    tsptr->InitServer();
    tsptr->Loop();
    


    return 0;
}
